finish implementing matching functionality