started porting to emscripten