fixed counter off by one