Altered millis() placement for more accurate timing of the thread