fixed code for gallery