[refactor] reduce memory usage