Rewrite input logic by piping