re-ordered api calls for readability