Solve append event listen probelm, clean up js code