Added validation and error messages