gallery refactoring