implement the server function