removed pointless next if get_mode at end