There is an post where I present a timer object that encapsulates millis() completely. This makes the approach more simple.