added memorising function