Fix duplicate code and fix XSS bug

XSS POC here: http://www.csclub.stthomas.edu/aboutUs.php?name=Braden);alert(%22Hi%22