improve node stdout workaround to work in closure