added some events and a funcction that updates the counters