Added function to validate submitted data