Added simple error handling.