Modified the join function