fixed some bugs in pipe