Refactoring of the solution