added error checking to pipe system calls