final code for hw3