refactor image generator