further adjusted the signal handling