its working for 5x5 grid. not sure why it does not work for 20x20 grid.