Rewrite in JS, again.