improved error handling;