updated server function