updated to use templates