more elegant group switching