refactor controllers for gallery