splitted match functionality to two methods