fixed logic in pipes.c