added apply_pipe function