Adding timeouts in loops