refactor image processor code