modified choose_mode_S