moved implementation details of subscript out into a separate file