added validation for required fields