fixed keyerror in key derivation