We will be writing more indices so I'm trying to clean this up a bit before this function gets too messy Signed-off-by: William Casarin <jb55@jb55.com>