fixing the seg fault