fix return value in case of error