Added javascript implementation