refactored and added build all chain