Fix bug when creating dictionary