gallery refactored