template implementation