add dynamic determination of grid size