fix counter function, replace counter file after count++