Updated grid layout code