improved gallery saving