fix math and text mode in cases