fixing alg