Refactored, runs in 0.045s