Fixed bug where only 2 first sub patterns were taken in account