Fix Next Dictionary Issue, Refine Code