refactored visualization functions