remove more use of memory function