fixed math error and html escaping