updated with hw3.3 solution