Extract conditions into local function

Using a function with a meaningful name makes the
check more readable.