I think the code will work, just not quite sure that the joins should be in this function.