A doctest here would really help me understand how this function works.