fixing record matching routine
added test script for record selection code