refactor update gallery code