fix key generation part