code refactor and streamlined; allow merge config