Refactored, Runs in 4.2s