compiles but segmentation fault upon running