Rewrite using dart:js