use an event counter instead of a loop

Link: https://github.com/GeneAssembly/biosal/issues/558
Signed-off-by: Sébastien Boisvert <boisvert@anl.gov>