refactored. making Indices instance on stack, when needed