helper for getting list indices properly