refactor initialization into functions