Changed method to get exit code