code refactoring... (grid.js)