code refactoring:
- use var at the first lines unless it is some counter
- use '+= 1', '-= 1' instead of ++, -- for  jslint warnings