update gallery function