added data validation and error display