slight refactoring of visualizer.js