Fixing bug with search on last element.