Edited for Part 1 of homework 6