changed conditonal to be based on the existence of stdout