finally figured out the improper pointer type in join function