Completed Homework 3 Code