more functions added to get templates running more smarter