refactor galleries