js example slightly modified