better error handling for production