Adjust code for gallery