code refactor for image assign to product