Added an undefined check to html function