extracted function, use thread-last macro to clean up get-best-match function