20 solution refactored