adding in tls config and refactor