changed handling of regex generation