refactor again, now for api servers