complete server function