finished js conversion