Refactor of save memory