Changed from stragey pattern to template pattern