out of array index error found, added try catch handler