These kind of checks may be worth extracting to a helper.