temp version with comparing not valid pattern relative on currentPos
fixed loop (with wrong error)