render to image, refactor