Made function use template