Fix a bug in appendJS