That is a nice idea, although in `posWithinRange` the end is inclusive, so it might need an extra parameter to have it exclusive for this case, which might make the code a bit more complicate to read, but it would be shared, and since `posWithinRange` is an useful API, the new addition might become useful too.