check before generating key