Fixed counter to simplify loop and fix race. Renamed for clarity.