trying to find seg fault in code