refactor range/cursor conversion functions