factor out long conditional into own method