use a latch to avoid busy loops