Refactored the use of match_item.
Removed old db query code.