template recognition code backup