refine gallery layout