factor out data to build function