improved error handling #4