Changed error handling