refactor to eliminate tangles