updated exit code handling