solved array index issue with grid