changed gallery code