fixed main_server code