moved isDisjoint to function