refactoring edit image