refactored reverse_index