WIP
Now works in javascript