move logic from match method to individual methods