diff --git a/search/first_occurance.py b/search/first_occurance.py
index <HASH>..<HASH> 100644
--- a/search/first_occurance.py
+++ b/search/first_occurance.py
@@ -7,16 +7,19 @@
 import unittest
 
 def firstOccurance(array, query):
-    lo, hi = 0, len(array)
-    while lo < hi:
-        mid = lo + (hi - lo) // 2
+    lo, hi = 0, len(array) - 1
+    while lo <= hi:
+        mid = (hi + lo) // 2
         #print("lo: ", lo, " hi: ", hi, " mid: ", mid)
-        if array[mid] < query: lo = mid + 1
-        else: hi = mid
-    if lo < len(array) and array[lo] == query:
+        if lo == hi:
+            break
+        if array[mid] < query:
+            lo = mid + 1
+        else:
+            hi = mid
+    if array[lo] == query:
       return lo
 
-
 class TestSuite(unittest.TestCase):
 
     def test_firstOccurance(self):
Update first_occurance.py

Incorporated review comments for <URL>