Modified for HW3 Part 3.