update code to work with JOIN instead of comma; part 2