Factor out loop from double-declining calculation