fix a bug with nil quantities