Added prevention infinite loop if wrong template