One thing I am concerning: is it good to resize a vector frequently? But in this way, the code seems much more clear than have an outputs and a new_outputs.