Refined implementation.
bench: 3869629