Improved capturing of the output