Add comments for visualization to remove code duplication