refactoring grid utilities