Mixed up of JS
Fix bugs and add "insert results"