improve error handling;