Remove visualization function and refactoring