fix counter issue with clear()