using template function, have bugs