refactor gallery