here we prefer to use as less memory as possible