refactoring how to load images