Refactor code related to col/row ranges