refactor remove and indexOf