refactor grid functions to their own section