Reference code for homework 3.