fixing segmentation fault on linux