fixing a seg fault