Integrated code from lab 4 into lab 5 base code