fixing indexof bug