check if a given key exists in a dictionary