add final logic to rotate grid