New algo with count running memory method