image comparison & refactoring