ex3/1 visualization code