fixed the x and y position saving in javascript, previously was always updating the values