finished problem 2.5 for cs262