replaced return statements with exit(-1) in thread functions