implemented problem 2 #1 and briefly tested.