refactoring and make data structure easier to understand