v2  - fixed the case with pattern of length 1 when was creating a vector with length 0 and trying to access its first element