recovery: move range subroutine to ranges.py