updated with exception catch