image extracting refactoring