improve template function _set()