refactoring dict management and adding get_state