Updated with smarter templates