Move free logic into its own function, so we can call in in both places.