template method implementation