Added 'output' template portion to 'contains' calculation.