Part 1 of #5 solution