How to code a counter for keep counting the transaction that going on?