refactored image gallery creation. separation of concerns