Refactor where condition in a static function