fixed remainingCd ever becoming < 0