Fixing deep recursion issue with merge