Corrected "generateKey()" method