Stdout handling addded