grid refactoring