regexp optimization and restructred variable defenition