convert to pure js