- addOptionalPattern method added and tested