refactory templateMethod