Moved code to retrieve template parameter names to a separate function for easier reuse.