adjusted returncode checking