changed function syntax and removed nested functions out of StartServer