Added exit code checking