Refactored message validation