change gallery.js to oop