Added exit code handling