Parameterize the wait count logic to work on any number of strands