Switch to better javascript API