converted examples over to pure javascript