cleaned up code foramtting but I do not see obvious errors causing the html bug