Written code for validation