refactoring visualization code
still refactoring