image processor - code refactoring