split build and apply routines into separate files so we can include subroutines