implementing templaet-based approach