Use correct logic for updating counter