added try-catch block for view event