My solution for the grid exercise