change event counter system to being more safe