Use a countdown latch instead of sleeping