added fork error checking