loop to get the top matching images