inprove the error handling. More information is pronted in case of error