Slow algorithm. Slows down when items exceed 20.