refactors for the js library, new api calls amend later