half of homework 3, this one is taking a while