Corrections to script so icons are not inserted multiple times into the page