max_cols variable added to get the 'grid_size'