refactored gallery uploads