revision of usage of lastkey, much safer