Pull linearring handling into function