extract complex condition into method for readability