As Paul McKenzie mentioned, why do you use both 'units' and 'quantity'? The user input is placed in 'units', but your if-statements etc. are using 'quantity'.

- petter