gallery small refactoring