fixed bug for random fault (seg fault) (maybe)