Refactor solution 1