fixed possible segmentation fault