Added error handling and logging #74