improve mode choice logic