complete join plan function