fix some javascript, change scaling function