fixed bug in the targetting logic
moved ui js to a new file so that only the simulator core is left in
sim.js