preparing to merge with map
cleaned up weighted.js code