betterd JS simulation, fixed trajetory error