more effficient memory handling