fixed bugs in match() statement