Reference code for homework 2.