fixed segmentation fault
fixed segmentation fault
fixed segmentation fault
added quit function