converted to use template