implementing signal handling