moved grid code into separate controller