added try catch block to index