add try...catch for regex generatng