refactoring for Dictionary class