added code for validation