fixed a bug in the pipe implementation