moved grid update code into its own func