refactored m101p week 2 homeworks