fixed bug in join statement'