Fix empty vector handling bug