added 'on' clause to left joins