Improved the inserting of matches in db