Fixed error with key generation