Section 3.1 of the assignment
Working version