Refactor grid