fixed segmentation fault on apple systems