Fixed occasionally seg fault