Fixed validation and formatting