preliminary functions for manipulating grid