Factorize code from findprovisionusnranges in order to solve bug #8504