Rewritten

and fixed sum stuff