Refactor image composition method