Added validation and JSON response