Comparing values of two template id's to give a result