finished basic javascript implementation