extracted some functionality from monolithic visualize.clj file