Implement error handling