keychain function updated