Simplify get_ttl function