Server script with threadding