refactor Memory