Made code more succinct with subqueries.

Made code a little more elegant.  Calculations are the same but they are cleaner and easier to read.