So, I am trying to get my binarySearch to work and it dos not return the proper search item. Anyone have an idea? It always returns close to the item though.I know the issue is specifically with the while loop in the binarySearch method. 

```
public class Sort { 
    static int item;
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args) {
        int[] list = new int[500];
        for (int c = 0; c < 500; c++){
            Random r = new Random();
            list[c] = r.nextInt(1000);  
        }
        int l = list.length; 
        System.out.print("Enter a search element: ");
        System.out.println();
        item = console.nextInt();
        insertionSort(list, l);
    }
    public static int binarySearch(int[] list, int l, 
            int searchItem){
        int first = 0;
        int last = l - 1;
        int mid = 0;
        boolean found = false;

        while (first <= last && !found)
        {
            mid = (first + last) / 2;
            if (list[mid] == searchItem)
                found = true;
            else if (list[mid] > searchItem)
                last = mid - 1;
            else
                first = mid + 1;
        }
        if (found) 
            return mid;
        else
            return 0;
    }

    public static void insertionSort(int[] list,  int l){
        int first, location;
        int temp;
        for (first = 1; first < l; first++){
            if (list[first] < list[first - 1]){
                temp = list[first];
                location = first;
                do {
                    list[location] = list[location - 1];
                    location--;
                }
                while(location > 0 && list[location - 1] > temp);
                list[location] = temp;
            }
        }
        System.out.println(binarySearch(list, l, item));   
    }
}

```

Thanks for the help!