fixed addUnit() to work with the circular buffer