checkExitCode function
code clean