adding code for validation