use precompiled regex pattern instead of compiling regex every call