added self memorizing function