refactored api server out