photo upload refactored