Modified for HW3 part 3