refactored version building