changed location of the declaration of sortedLayouts and sortedPhotos