fix an alg bug