added some code for selecting the closest matching demo