Added validation and error handling to the demo