better handling of regexp compile