fixed error messages
more error handling