Adding validation code for Task 2