optimize grid