added counter circuit