Complete new attempt at grid scanner.js