Updated if statement for a key which is already set