account for shared domains and ksort directives array #2797
refactor & update comments #2797