refactored build process to be simplier and more generic