init grid in function