added missing try catch for exception handling