added validation

added validation and formatting