Made counter work properly