Refactoring the grid