made some more changes to step 3 since there were 2 queries doing much of the same thing, unnecessarily.