Added code for pattern matcher