Template method used for generation