added templated code