TODO: make pipe interface correct