fixed the key generation