Replaced prefix summing with Phil's version

Now uses sum() instead of mvars and a loop