fixed bug#2 and add SIGINT ctr-c handler