Solution to 23. Could be faster.