refactor scan.go, better variable names, get rid of external counter in for loop