Refactor of the solution for Problem #15