added try catch block for basic exception safety