more javascript, ready for algorithm