improved build routine