Added Javascript implementation2