Fixed the bug!!!

Had to define my own function though, shame on indexOf!