Improve the grid state listener