tls: simplify code