grid size autodetection