Move server function to server directory