New Grid Layout algorithm for the viewer