Fixing outer join related issue