unit building logic. not tested