bounded variable algorithm