separate out the visualizing code from html