migrate lib to pure js