refactored 32 solution