Simplify dictionary switching code