Added backtracking to adding a match to the database