Now using templates instead of seperate functions for each data type.