merge and rebuild