Segfaults on iteration 2, uncleary why