code rewrite - splitting the Grid class into distinct Classes and Modules