moved $build calculation to main routine to make it available everywhere