draft implementation of potem in js