use semaphors rather than latches