fix left join queries