fixed a bug in the GS-alg