modify template algorithm. (is properly operate, 2 to 8 photo template)