Fixed potential indexof error