adding template exists check