Updated return code check