working out seg fault