clean up error handling