jquery autocomplete not clearing choices?

jquery autocomplete not clearing choices?

I was just playing around with jquery autocomplete. I've set the minimum length to 3.

if I typed in the letters "sci" it would then get all records that has the letters "sci" in the title. This part is **working** correctly as all records with the letters "sci" are returned and displayed.

But if say I continue typing (after a pause of course. at this point I typed "scisdfgdsfsd"), it still displays the previous choices. There are certainly no records with titles using the letters "scisdfgdsfsd" in it.

Any ideas on how to fix this? thanks! :)

------------------------------------------

screenshots of the "error" in action

working: http://awesomescreenshot.com/0a2wuo2aa

not working: http://awesomescreenshot.com/023wuo507

my jquery code

    $(function() {
        $("#course").autocomplete({
            minLength: 3,
            source: function( request, response ) {
                $("#commentsSection").hide();
                $("#instanceIdSection").hide();
                $.getJSON("/issu/GetCourses.html", {term: request.term}, function(data, status) {
                    if (data.length > 0) {
                        response(data);
                    } else {
                        getEventComments();
                        getEventSessions();
                    }
                });
            },
            select: function (event, ui) {
                alert("select");
                getEventComments();
                getEventSessions();
            },
            change: function (event, ui) {
                alert("change");
                getEventComments();
                getEventSessions();
            }
        });
       
        function getEventSessions(){
            $.getJSON("/issu/GetEventSessions.html",{description: $("#course").val()}, function(data, status){
                if (data.length != 0) {
                   
                    $("#instanceId").empty();
                    $.each(data, function () {
                        $("#instanceId").append($('<option></option>').attr("value", $(this)[0]).text($(this)[1]));
                    });
                    $("#instanceIdSection").show();
                }
            });
        }
       
        function getEventComments() {
            $.get("/issu/GetEventComments.html",{description: $("#course").val()}, function(data, status){
                if (data.length != 0) {
                    $("#comments").text(data);
                    $("#commentsSection").show();
                }
            });
        }
    });