replace some loops with static method switcher