added debug info and segmentation fault bug