fixed problem with gallery code