fix crash when buying more than maximu capacity