Fix misuse of Array.indexOf()
cleanup