returncode handling fixed, output captured