added extra condition to appendHTML check to ensure there are no duplicates