fixed broken beginpattern, endpattern