original hw3 code provided