fix primitive root generator