Code added for task 4