This mid doesn't work. It works only for left = 0.
e.g.: left = 5, right =15 => your mid = 5, actual mid = 10