fixed previous commit. stores final amount to the console.