working on js version