check for keys before assigning the values