added scan and match pattern