simplified plot js code