fix to error in join query