refactor: port to sane javascript