Fixed a bug in matching