Added isset check for availableCount to avoid PHP notice.