Improve question 14 solution