give proper error codes when there's an error