add one more condition middle == head