moved tls-server stuff together within the if