Consolidating getBestImage logic