added try catch and to delete the entries