Fixing a JS offset issue