why rindex is used here?