changed to use template system