add error handling for validation