improved the visualization function.