make counter (i) non global
Merge pull request #61 from locomote/remove-globals

Make counter (i) non global