bgs algorithm updated