fixed some bugs in javascripts dynamic content