refactor image creation