Refactored 23 to be simpler and more efficient.