updated gallery code.