visualization code cleaned up