fixing record matching routine