fixed index lookup bug