add the new API, should make this code infinitely simpler