Added simple error handling