this runs sometimes but segfaults on others