use key in dictionary instead of direct check