added code to avoid blinking when the starting duration is less than 20 seconds