fixed some bugs in gen alg