Solution 21 added, solution 23 refactored