fix a bug in NKQ generator