minor grid code refactor