fixed total number bug, added allowed templates option