added message validation function