improve memo function