fix bug in counter, and fix bug with file check