Refactored image loading