fixed pipe and some bugs