clarified code find_index