tear down functions into several functions