refactored error handling - exceptions wrapped in Try