modified HW 4 to be more accurate