fixed stdout stderr handling