reorganization of grid.js