working leapfrog method