Added reference. Moved constant terms out of the loop.