lots of changes to support indexes as return type