first working version: global counter only