Solved problem 67, refactored solution 18