refactoring jpg