improve visualizer. optimize visualizer functions