would be better to extract the condition in a separate helper method