fix a bug of keygen