Fixing bug with head == tail.