js bug with appendChild fixed