rewrite of memory function api