cleanup of error handling