updated signal handler function