Eliminate unecessary join