Modularized the code, added new class Pipe