using indexof instead of binsearch