Typed in code from HW3 part 2