BEtter use of indexof