added encoder counter