use key in dict instead of dict.keys()