added counting latch