Fixed a bug in keypairs