begin to change to pure js version