Created new delay_ms function to solve optimization errors