Just to keep the code a bit clean: can you move this a few lines below, where we set api_port?