updated the grid code to support proper handles