fix key derivation