added validation for messages