implemented match logic