Program 5, builds upon 3 and 4