completely rewrote the api