That's more complicated. Maybe a loop searching for that previous pulse? That's not a trivial thing to do. IMHO, the easiest solution is storing the info of each pulse on a variable and as soon as a new pulse is detected, move it to a second variable. That way the bot can find the info of the most recent one and the immediately previous one.