..and we can also optimize away the ">" comparisons, but the basic idea is right.