Part 1 of #6 solution