this is not threadsafe, key creation must be done under a lock