Changed error handling structure