adding generate key function