Improved word intersection logic