legend toggle is not perfectly working