changed this one to use joins