refactor code of TargetVisualizer