improved error handling
improved error handling