Proposed solution for homework 2.