fix join conditions