fix gallery saving