Removed accidental global variable 'amount'