implmented template analysis