Added validation and formatting