complete join function