added function for Question 3