finished with API (untested)