rewrote all of join code