working grid solution finally