Implemented simple error handling