better stdout and stderr handling