updated inArray method for template background image population.