I think that the program is ready to use.
The performance of recognizePattern can be way better if  I split the