Moves grid logic to own file