better message type checking