first try to create a pure js version