added indexof and checking variables array