add template type
 refactor type for template args
 add stream template arg validate