add memo function.
not tested.
secondary changed function Memory;
not tetsted.