Added error handling for production environments