templating redone to be more generalized