Use correct variable to compile regex