added a check to set up key if it does not exist yet.