this *seems* to work, but needs further testing.