Help with a pulse detection func

There goes 80% of all problem-with-the-code threads....

You say that like it's a bad thing. 8)