yes, what @ScruffR said.
This phrase jumped out to me. I recalled an earlier post which discussed millis() and rollover which I used to straighten out my code, at the time. My thought was this might have been why you were given the code in the main block (5 lines).
https://community.particle.io/t/millis-and-rollover-tutorial/20429