improve performance,pattern match takes long time