What Arduino is this running on?
There’s something fishy about those zero returns from millis(). Never seen that on my Nanos. The variables are globals, are written once each when you call millis(), and should have valid non-zero values when you do the initialization of duration. My comment before was with regards to the likelihood that they are the same, thus returning zero for a delta value, but the two timestamps should not be zero.