fix key generation