refactored mathjax support