Refactor solution