optimizing galleries - first draft