Refactored Grid class