improve regex code
improve for mem usage