remove the global var server,modified to be in the function arg.