Refactor example js slightly