fix unclosed tags error; change html parsing to function