adding solution to exam2 problem