rewrite error messages in receive function