Can we do something more deterministic here e.g. maintain a state in the grid, relying on the template is a hack and if we change something there it will break this code