handling loading states on gallery