fix return code in case of error