Restructured code and added jquery plugin so display math works and looks better.