Corrected grouping logic and added game board printing