updated solution code to Problem 2.1