moved assignment specific code from generate_image to own file