Final code for hw3