Updated Code for pattern match for the visual search tool.