range stealing algorithm