This complex condition is a good candidate for a private method.