Added code from problem 2.3, 2.4 and 2.5