port to javascript