Solved javascript insertion problem