fix in join statement construction for deeper relationships