refactored first_larger_index method